# Maintainer: Michał Polański <michal@polanski.me>
pkgname=kondo
pkgver=0.8
pkgrel=0
pkgdesc="Cleans dependencies and build artifacts from your projects"
url="https://github.com/tbillington/kondo"
license="MIT"
arch="all"
makedepends="cargo cargo-auditable"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/tbillington/kondo/archive/v$pkgver/kondo-$pkgver.tar.gz"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release

	target/release/kondo --completions bash > $pkgname.bash
	target/release/kondo --completions fish > $pkgname.fish
	target/release/kondo --completions zsh > $pkgname.zsh
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/$pkgname -t "$pkgdir"/usr/bin/

	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish "$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
62cf51c7db440fa36d33206759a60b084a1c98fc718988cfa01c417ad1eb4e6a930e3c66e83d2ae9fc169acb93c98ed18fe8cf4ca3ab5a40d2adbfa27363f9a0  kondo-0.8.tar.gz
"
